home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / gfx / lise2.1 / lise / src / lbn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-31  |  1.1 KB  |  49 lines

  1. /*
  2.   change the time calibration factors of all files specified
  3.   Abbreviation comes from
  4.   Late is Better than Never
  5. */
  6. #include <stdio.h>
  7. #include <math.h>
  8.  
  9. main(argc,argv)
  10. int argc;
  11. char *argv[];
  12. {
  13. int n,i,m,fd;
  14. unsigned char a1,a2,a3,a4;
  15. float tica;
  16. union fourbytes {
  17.     float               real;
  18.     long int            sig;
  19.     unsigned long int   card;
  20.       } b4;
  21.  
  22.   if(argc<3) { /* print help message */
  23.     printf("changing the time calibration factors of all spectra specified\n");
  24.     printf("Abbreviation stands for: Late is Better than Never\n");
  25.     printf("Call like\nlbn 0.03456 *.err *.spc\n");
  26.   }
  27.  
  28.   tica=(float)atof(argv[1]);
  29.  
  30.   b4.real=tica; m=b4.card;
  31.   a1 = m / 16777216 ;
  32.   m  = m - (a1 * 16777216);
  33.   a2 = m / 65536;
  34.   m  = m - (a2 * 65536);
  35.   a3 = m / 256;
  36.   m  = m - (a3 * 256);
  37.   a4 = m ;
  38.   for(n = 2 ; n < argc ; n++) {
  39.      fd=open(argv[n],1,0666);
  40.      printf("touching %s fd= %d , tica = %f\n",argv[n],fd,tica);
  41.      lseek(fd,84L,0);
  42.      write(fd,&a1,1); write(fd,&a2,1);
  43.      write(fd,&a3,1); write(fd,&a4,1);
  44.      lseek(fd,0L,1);
  45.      close(fd);
  46.   }
  47.   exit(0);
  48. }
  49.